﻿using System;

namespace Hibiku.Twitter
{
    public class User : IFormattable
    {
        public long Id
        {
            get;
            private set;
        }

        public string Name
        {
            get;
            private set;
        }

        public string ScreenName
        {
            get;
            private set;
        }

        public string Location
        {
            get;
            private set;
        }

        public string Description
        {
            get;
            private set;
        }

        public string Url
        {
            get;
            private set;
        }

        public string ProfileImageUrl
        {
            get;
            private set;
        }

        public User(long id, string name, string screenName,
            string location, string description,
            string url, string profileImageUrl)
        {
            Id = id;
            Name = name;
            ScreenName = screenName;
            Location = location;
            Description = description;
            Url = url;
            ProfileImageUrl = profileImageUrl;
        }

        #region IFormattable Members

        public string ToString(string format, IFormatProvider formatProvider)
        {
            if (format == null) format = "G";
            format = format.ToLower();

            if (formatProvider != null)
            {
                var formatter = formatProvider.GetFormat(GetType()) as ICustomFormatter;

                if (formatter != null)
                {
                    return formatter.Format(format, this, formatProvider);
                }
            }


            switch (format)
            {
                case "u": return ScreenName;
                case "nu": return string.Format("{0} ({1})", Name, ScreenName);
                case "n":
                case "g":
                default: return Name;
            }
        }

        #endregion
    }
}
